﻿
@inject IPageService pService
@model PageEntity

@{
    ViewData["Title"] = "页面 编辑";
    Layout = "../Shared/_Layout.cshtml";
    string parentName = "根目录";
    if (!string.IsNullOrWhiteSpace(Model.ParentId))
    {
        var parent = pService.GetById(Model.ParentId);
        if (parent != null)
        {
            parentName = parent.LocalName;
        }
    }
}
<style>
    .jstree ul li {
        text-align: left;
    }
</style>
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row">
        <div class="col-lg-12">
            <div class="ibox float-e-margins">
                <div class="ibox-content text-center p-md">
                    <form id="dynamic-form" asp-action="Edit" method="post" class="form-horizontal" role="form">
                        <div asp-validation-summary="@ValidationSummary.All" class="text-danger"></div>
                        <input type="hidden" asp-for="PageId" />
                        <input type="hidden" asp-for="ParentId" />
                        <div class="form-group">
                            <label for="ParentId" class="col-md-3 control-label text-right">上级菜单</label>
                            <div class="col-md-9" style="position:relative;">
                                <input name="ParentName" id="ParentName" value="@parentName" class="form-control select-tree" placeholder="上级菜单" readonly tree="{treeid:'.jstree-select',roottext:'根目录',parent:'ParentId',id:'PageId',text:'LocalName',fieldvalue:'#ParentId',fieldtext:'#ParentName',ajaxUrl:'/admin/page/getchildren'}" />
                                <div class="jstree jstree-select">
                                </div>

                                <span asp-validation-for="ParentId" class="text-danger"></span>
                            </div>
                        </div>
                        <div class="form-group">
                            <label asp-for="LocalName" class="col-md-3 control-label text-right">页面名称</label>
                            <div class="col-md-9">

                                <input asp-for="LocalName" id="txtUserName" validate="{required:true}" maxlength="16" class="form-control" placeholder="页面名称" />
                                <span asp-validation-for="LocalName" class="text-danger"></span>
                            </div>
                        </div>
                        <div class="form-group">
                            <label asp-for="OrderNum" class="col-md-3 control-label text-right">排序</label>
                            <div class="col-md-9">
                                <input asp-for="OrderNum" type="text" class="form-control touchspin3" max="10000" min="0" validate="{required:true}" />

                                <span asp-validation-for="OrderNum" class="text-danger"></span>
                            </div>
                        </div>
                        <div class="form-group">
                            <label asp-for="ActionName" class="col-md-3 control-label text-right">ActionName</label>
                            <div class="col-md-9">
                                <input asp-for="ActionName" class="form-control" validate="{required:true}" maxlength="50" />

                                <span asp-validation-for="ActionName" class="text-danger"></span>
                            </div>
                        </div>
                        <div class="form-group">
                            <label asp-for="RouteUrl" class="col-md-3 control-label text-right">路径</label>
                            <div class="col-md-9">
                                <input asp-for="RouteUrl" class="form-control" validate="{required:true}" maxlength="100" />

                                <span asp-validation-for="RouteUrl" class="text-danger"></span>
                            </div>
                        </div>
                        <div class="form-group">
                            <label asp-for="Icon" class="col-md-3 control-label text-right">图标</label>
                            <div class="col-md-9">
                                <input asp-for="Icon" class="form-control" maxlength="16" />

                                <span asp-validation-for="Icon" class="text-danger"></span>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-md-3 control-label"></label>
                            <div class="col-md-9 text-left">
                                <div class="i-checks">
                                    <label asp-for="IsMenu"> <input asp-for="IsMenu" type="checkbox"> 是否菜单 </label>
                                </div>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-md-3 control-label"></label>
                            <div class="col-md-9 text-left">
                                <div class="i-checks">
                                    <label asp-for="IsDisplay"> <input asp-for="IsDisplay" type="checkbox"> 是否显示 </label>
                                </div>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-md-3 control-label text-right"></label>
                            <div class="col-md-9 text-left">
                                <div class="i-checks">
                                    <label asp-for="IsAdmin" class="i-checkbox"><input class="checkbox" asp-for="IsAdmin" type="checkbox" />是否系统菜单  </label>
                                </div>
                            </div>
                        </div>
                        <div class="form-group">
                            <div class="col-sm-4 col-sm-offset-2">
                                <a class="btn btn-white" asp-action="index">返  回</a>

                                <button class="btn btn-primary" type="submit">保存</button>
                            </div>
                        </div>

                    </form>
                </div>
            </div>
        </div>
    </div>

</div>
@section scripts{
    <script type="text/javascript">

        $(document).ready(function () {
            $(".form-horizontal").CustomForm({
                isValidate: true,
                isTable: false
            });

            $(".form-horizontal").submit(function () {
                if (!$(".form-horizontal").valid()) {
                    return false;
                }
            });




        });
    </script>

}
